package com.ljkj.cordial.chat.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.ljkj.cordial.chat.R;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ChatSendBoxAdapter extends BaseAdapter {
    private String[] typeNames = {"附件", "相册", "拍照", "视频录制"};
    private int[] typeIcons = {R.mipmap.dialog_btn_file, R.mipmap.dialog_btn_pic, R.mipmap.dialog_btn_camera, R.mipmap.dialog_btn_videocalls};

    @Override
    public int getCount() {
        return typeNames.length;
    }

    @Override
    public Object getItem(int position) {
        return typeNames[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_chat_send_box, null,false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        String name = typeNames[position];
        int iconId = typeIcons[position];
        holder.ivType.setImageResource(iconId);
        holder.tvType.setText(name);
        return convertView;
    }

    static
    class ViewHolder {
        @BindView(R.id.iv_type)
        ImageView ivType;
        @BindView(R.id.tv_type)
        TextView tvType;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
